
local nmgpackx = require "nmgpackx"
local skynet = require "skynet"

local t = ...
t = tonumber(t or 0)
print("t",t)

function func1()
	local tdt = {a=1}
	local stream,sz = nmgpackx:pack(tdt)
	print("pack",sz)
	local rs = nmgpackx:newdata(stream,sz)
	print(rs,rs[1],rs[1][1],rs[1][2])
	print(skynet.tostring(rs[1][1],rs[1][2]))
end

function func3()
	local tdt1 = {a=1}
	local stream1,sz1 = nmgpackx:pack(tdt1)
	local tdt2 = {b=1}
	local stream2,sz2 = nmgpackx:pack(tdt2)
	local stream,sz = nmgpackx:combineUserdata(stream1,sz1,stream2,sz2)
	local rs = nmgpackx:newdata(stream,sz)
	print(rs,#rs)
	for _,dt in ipairs(rs) do
		local fuldata,bsz = unpack(dt)
		print(skynet.tostring(fuldata,bsz))
	end
end

if t == 1 then
	func1()
elseif t== 2 then
	for i=1,10000 do
		func1()
	end
elseif t== 3 then
	func3()
end

print("end")